package io.yizoo.core.flow;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import io.elm.core.CoreController;

import java.util.*;


import io.elm.core.CoreMapper;
import io.yizoo.business.entity.biz_hrm_ei_basic;
import io.yizoo.system.entity.*;
import io.yizoo.system.mapper.sys_flowMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/system/flow/designFlow")
public class FlowDesigner extends CoreController {

    @Autowired
    private CoreMapper coreMapper;

    @Autowired
    private sys_flowMapper flowMapper;

    public List<?> GetOneRoadFlowListPage(String jsonStr) {
        //String user_id = Ctor.getCurrentUserId();//当前登录用户id
        List<?> ret = Ctor.CoreMapper.USelect(
                Ctor.DMaker(jsonStr).Selector
                        .Select("flow.*,f_form.table_name")
                        .From(fw_flow.class,"flow")
                        .innerJoin(fw_flowsec_form.class,"f_form","f_form.flow_id = flow.id")
                        .IsWhere("and flow.title LIKE CONCAT('%', #{name}, '%')","name")
                        .Where("and IFNULL(flow.on_canvas,'no') != 'yes'")
                        .OrderBy("flow.order_number")
                        .IsPage()
                        .GetFactor());
        return ret;
    }
    public List<?> GetFlowListPage_OnCanvas(String jsonStr) {
        List<Map<String,Object>> ret = Ctor.CoreMapper.USelect(
                Ctor.DMaker(jsonStr).Selector
                        .From(fw_flow.class,"flow")
                        .IsWhere("and flow.title LIKE CONCAT('%', #{name}, '%')","name")
                        .IsWhere("and flow.code = #{code}","code")
                        .Where("and IFNULL(flow.on_canvas,'no') = 'yes'")
                        .OrderBy("flow.order_number")
                        .IsPage()
                        .GetFactor());
        return ret;
    }
    public List<?> GetFlowListPage_All(String jsonStr) {
        List<Map<String,Object>> ret = Ctor.CoreMapper.USelect(
                Ctor.DMaker(jsonStr).Selector
                        .Select("flow.*,f_form.table_name")
                        .From(fw_flow.class,"flow")
                        .LeftJoin(fw_flowsec_form.class,"f_form","f_form.flow_id = flow.id")
                        .IsWhere("and flow.title LIKE CONCAT('%', #{name}, '%')","name")
                        .IsWhere("and flow.code = #{code}","code")
                        .OrderBy("IFNULL(flow.on_canvas,'no'),flow.order_number")
                        .IsPage()
                        .GetFactor());
        return ret;
    }
    public List<?> GetFlowList(String jsonStr) {
        List<Map<String,Object>> ret = Ctor.CoreMapper.USelect(
                Ctor.DMaker(jsonStr).Selector
                        .From(fw_flow.class,"flow")
                        .IsWhere("and flow.title LIKE CONCAT('%', #{name}, '%')","name")
                        .IsWhere("and flow.code = #{code}","code")
                        .IsWhere("and flow.id = #{id}","id")
                        .GetFactor());
        return ret;
    }

    public Object GetFlowCodeForCreate(String jsonStr) {
        List<Map<String,Object>> check = Ctor.CoreMapper.USelect(
                Ctor.DMaker().Selector
                        .Select("IFNULL(MAX(code),'nothing') AS code")
                        .From(fw_flow.class)
                        .Where("AND code LIKE 'flow_%' ")
                        .GetFactor());
        String code_str = "flow_";
        if(check.size()==0 || check.get(0).get("code").toString().equals("nothing")){code_str = code_str+"0001";}
        else{
            String ccc = check.get(0).get("code").toString();
            String[] cList = ccc.split("_");
            int cNum = Integer.parseInt(cList[cList.length-1]);
            String cStr = ""+(cNum+1);
            if(cNum<1000){cStr = "0"+cStr;}
            if(cNum<100){cStr = "0"+cStr;}
            if(cNum<10){cStr = "0"+cStr;}
            code_str = code_str+cStr;
        }
        Map<String,String> result = new HashMap<String,String>();
        result.put("code",code_str);
        return result;
    }
    public Object GetSecForm(String jsonStr) {
        ObjectNode data = Ctor.getObjectNode(jsonStr);
        String flow_id = data.get("flow_id").asText();

        List<Map<String,Object>> result = Ctor.CoreMapper.USelect(
                Ctor.DMaker().Selector
                        .Select("table_column")
                        .putFactorItem("flow_id",flow_id)
                        .From(fw_flowsec_form.class)
                        .Where("and flow_id = #{flow_id}","flow_id")
                        .GetFactor());

        return result;
    }
    public Object UpserFlowAndSecForm(String jsonStr) {
        ObjectNode data = Ctor.getObjectNode(jsonStr);

        JsonNode flowData = data.get("model");
        String flow_id = flowData.get("id").asText();
        String flow_code = flowData.get("code").asText();
        String ff_tablename = FlowType.getJsonNodeItemTextNull(flowData,"ff_tablename");

        //更新数据库
        UpsertFlow(jsonStr);
        UpsertFlowSecFormData(flow_id,flow_code,null,null,ff_tablename);

        return true;
    }
    public Object UpsertFlowSecForm(String jsonStr) {
        ObjectNode data = Ctor.getObjectNode(jsonStr);

        String flow_id = data.get("flow_id").asText();
        String flow_code = data.get("flow_code").asText();
        String tColumnStr = data.get("form_item_str").asText();

        return UpsertFlowSecFormData(flow_id,flow_code,(ArrayNode)data.get("form_item"),tColumnStr,null);
    }

    public Object GetDataForNodeCheckEdit() {
        List<Map<String,Object>> role_list = Ctor.CoreMapper.USelect(
                Ctor.DMaker().Selector
                        .Select("id,name")
                        .From(sys_role.class)
                        .OrderBy("name")
                        .GetFactor());
        List<Map<String,Object>> org_list = Ctor.CoreMapper.USelect(
                Ctor.DMaker().Selector
                        .Select("id,name")
                        .From(sys_org.class)
                        .OrderBy("name")
                        .GetFactor());
        for(Map<String,Object> org :org_list){
            List<Map<String,Object>> org_list_p = Ctor.HMapper.GetPath(
                    Ctor.DMaker().Selector
                            .putFactorItem("id",org.get("id").toString())
                            .From(sys_org.class)
                            .Where("and id=#{id}","id")
                            .GetFactor());
            String org_name_path="";
            for(Map<String,Object> orgP : org_list_p) {
                org_name_path = orgP.get("name").toString() + (org_name_path==""?"":"/") + org_name_path;
            }
            org.put("org_name_path",org_name_path);
        }
        Map<String,Object> result = new HashMap<String,Object>();
        result.put("role_list",role_list);
        result.put("org_list",org_list);

        /*
        List<Map<String,Object>> user_list = Ctor.CoreMapper.USelect(
                Ctor.DMaker().Selector
                        .Select("uu.id,uu.user_name as name,CONCAT(oo.name,CONCAT('-',uu.user_name)) AS ee_name")
                        .From(sys_user.class,"uu")
                        .innerJoin(sys_org.class,"oo","uu.dept_id = oo.id")
                        .OrderBy("oo.name,uu.user_name")
                        .GetFactor());
        */
        //result.put("user_list",user_list);

        return result;
    }
    public Object GetNodeCheckData(String node_id) {
        List<Map<String,Object>> check_list = Ctor.CoreMapper.USelect(
                Ctor.DMaker().Selector
                        .putFactorItem("node_id",node_id)
                        .Select("*")
                        .From(fw_flow_node_check.class)
                        .Where("AND flow_node_id = #{node_id}")
                        .GetFactor());
        List<Map<String,Object>> check_param_list = Ctor.CoreMapper.USelect(
                Ctor.DMaker().Selector
                        .putFactorItem("node_id",node_id)
                        .Select("param.*,uu.user_name AS uu_user_name")
                        .From(fw_flow_node_check_param.class,"param")
                        .LeftJoin(sys_user.class,"uu","uu.id = param.value")
                        .Where("AND param.flow_node_id = #{node_id}")
                        .GetFactor());
        Map<String,Object> result = new HashMap<String,Object>();
        result.put("check_list",check_list);
        result.put("check_param_list",check_param_list);
        return result;
    }

    public Object UpsertFlow(String jsonStr) {
        ObjectNode data = Ctor.getObjectNode(jsonStr);

        String user_id = Ctor.getCurrentUserId();//当前登录用户id

        JsonNode flowData = data.get("model");

        String flow_id = flowData.get("id").asText();
        fw_flow flowModel = new fw_flow();
        flowModel.setId(flow_id);
        flowModel.setCode(flowData.get("code").asText());
        flowModel.setTitle(flowData.get("title").asText());
        flowModel.setOn_canvas(FlowType.getJsonNodeItemTextNull(flowData,"on_canvas"));
        flowModel.setRemark(FlowType.getJsonNodeItemTextNull(flowData,"remark"));
        flowModel.setOrder_number(FlowType.getJsonNodeItemTextNull(flowData,"order_number"));
        List<Map<String,Object>> check = Ctor.CoreMapper.USelect(
                Ctor.DMaker().Selector
                        .Select("id")
                        .putFactorItem("code",flowModel.getCode())
                        .From(fw_flow.class)
                        .Where("and code = #{code}","code")
                        .GetFactor());
        if(check.size()>1){return false;}
        else if(check.size()==1){
            if(!( flow_id.equals(check.get(0).get("id").toString()) )){return false;}
        }
        else {
            flowModel.setSys_createtime(new Date());
            flowModel.setSys_createuser(user_id);
        }

        Ctor.HMapper.Upsert(flowModel);

        return true;
    }

    @Transactional
    public boolean DeleteFlow(String flow_id) {
        Ctor.CoreMapper.UDelete(
                Ctor.DMaker().Deleter
                        .putFactorItem("flow_id",flow_id)
                        .From(fw_flow.class)
                        .Where("AND id = #{flow_id} ", "flow_id")
                        .GetFactor());
        Ctor.CoreMapper.UDelete(
                Ctor.DMaker().Deleter
                        .putFactorItem("flow_id",flow_id)
                        .From(fw_flow_param.class)
                        .Where("AND flow_id = #{flow_id} ", "flow_id")
                        .GetFactor());
        Ctor.CoreMapper.UDelete(
                Ctor.DMaker().Deleter
                        .putFactorItem("flow_id",flow_id)
                        .From(fw_flow_line.class)
                        .Where("AND flow_id = #{flow_id} ", "flow_id")
                        .GetFactor());
        Ctor.CoreMapper.UDelete(
                Ctor.DMaker().Deleter
                        .putFactorItem("flow_id",flow_id)
                        .From(fw_flow_node.class)
                        .Where("AND flow_id = #{flow_id} ", "flow_id")
                        .GetFactor());
        Ctor.CoreMapper.UDelete(
                Ctor.DMaker().Deleter
                        .putFactorItem("flow_id",flow_id)
                        .From(fw_flow_node_check.class)
                        .Where("AND flow_id = #{flow_id} ", "flow_id")
                        .GetFactor());
        Ctor.CoreMapper.UDelete(
                Ctor.DMaker().Deleter
                        .putFactorItem("flow_id",flow_id)
                        .From(fw_flow_node_check_param.class)
                        .Where("AND flow_id = #{flow_id} ", "flow_id")
                        .GetFactor());
        Ctor.CoreMapper.UDelete(
                Ctor.DMaker().Deleter
                        .putFactorItem("flow_id",flow_id)
                        .From(fw_flow_node_cn.class)
                        .Where("AND flow_id = #{flow_id} ", "flow_id")
                        .GetFactor());

        //如果有对应fw_flowsec_form表记录，那么删除对应fw_flowsec_form表记录和表单数据表（如果有）
        List<Map<String,Object>> check = Ctor.CoreMapper.USelect(
                Ctor.DMaker().Selector
                        .Select("id,table_name")
                        .putFactorItem("flow_id",flow_id)
                        .From(fw_flowsec_form.class)
                        .Where("and flow_id = #{flow_id}","flow_id")
                        .GetFactor());
        if(check.size()>0){
            String fTableName =check.get(0).get("table_name").toString();
            Ctor.CoreMapper.UDelete(
                    Ctor.DMaker().Deleter
                            .putFactorItem("flow_id",flow_id)
                            .From(fw_flowsec_form.class)
                            .Where("AND flow_id = #{flow_id} ", "flow_id")
                            .GetFactor());
            //删除对应表单数据表
            try{
                Map<String,Object> ff = new HashMap<String,Object>();
                ff.put("table_name",fTableName);
                List<Map<String, Object>> ccff = flowMapper.FindTableByName(ff);
                System.out.println("【AAAA】表名检查 "+fTableName+" - "+ccff.size()+"个");
                if(ccff.size()>0){
                    int c = flowMapper.DDL_DropTable_FlowSecForm(ff);
                    System.out.println("【AAAA】删除表 "+fTableName+"  影响行数："+c);
                }
            }
            catch(Exception e) {e.printStackTrace();}
        }

        return true;
    }

    @Transactional
    public boolean DeleteNode(String node_id)  {
        int num = Ctor.CoreMapper.UDelete(
                Ctor.DMaker().Deleter
                        .putFactorItem("node_id",node_id)
                        .From(fw_flow_node.class)
                        .Where("AND id = #{node_id} ", "node_id")
                        .GetFactor());
        if(num==1){
            Ctor.CoreMapper.UDelete(
                    Ctor.DMaker().Deleter
                            .putFactorItem("node_id",node_id)
                            .From(fw_flow_line.class)
                            .Where("AND (start_node = #{node_id} OR end_node = #{node_id}) ", "node_id")
                            .GetFactor());
            Ctor.CoreMapper.UDelete(
                    Ctor.DMaker().Deleter
                            .putFactorItem("node_id",node_id)
                            .From(fw_flow_node_check.class)
                            .Where("AND flow_node_id = #{node_id} ", "node_id")
                            .GetFactor());
            Ctor.CoreMapper.UDelete(
                    Ctor.DMaker().Deleter
                            .putFactorItem("node_id",node_id)
                            .From(fw_flow_node_check_param.class)
                            .Where("AND flow_node_id = #{node_id} ", "node_id")
                            .GetFactor());
            Ctor.CoreMapper.UDelete(
                    Ctor.DMaker().Deleter
                            .putFactorItem("node_id",node_id)
                            .From(fw_flow_node_cn.class)
                            .Where("AND node_id = #{node_id} ", "node_id")
                            .GetFactor());
        }
        return num==1;
    }

    @Transactional
    public boolean UpsertFlowSecFormData (String flow_id, String flow_code, ArrayNode formItemList, String tColumnStr, String ff_tablename){
        //组装流程表单数据
        String fTableName = ff_tablename!=null?ff_tablename:"fw_flowsec_form_"+flow_code;
        fw_flowsec_form sFormModel = new fw_flowsec_form();
        List<Map<String,Object>> check = Ctor.CoreMapper.USelect(
                Ctor.DMaker().Selector
                        .Select("id,table_name")
                        .putFactorItem("flow_id",flow_id)
                        .From(fw_flowsec_form.class)
                        .Where("and flow_id = #{flow_id}","flow_id")
                        .GetFactor());
        if(check.size()>1){return false;}
        else if(check.size()==1){
            sFormModel.setId(check.get(0).get("id").toString());
            fTableName = check.get(0).get("table_name").toString();
        }
        else{
            sFormModel.setId(UUID.randomUUID().toString());
        }
        sFormModel.setFlow_id(flow_id);
        sFormModel.setTable_name(fTableName);

        //表结构信息字符串
        if(tColumnStr!=null && !tColumnStr.equals("")){
            sFormModel.setTable_column(tColumnStr);
        }

        //更新 fw_flowsec_form 表记录
        Ctor.HMapper.Upsert(sFormModel);

        //新建表单数据表（如果还没有）
        Map<String,Object> ff = new HashMap<String,Object>();
        ff.put("table_name",fTableName);
        List<Map<String, Object>> ccff = flowMapper.FindTableByName(ff);
        System.out.println("【AAAA】表名检查 "+fTableName+" - "+ccff.size()+"个");
        if(ccff.size()==0){
            int c = flowMapper.DDL_CreateTable_FlowSecForm(ff);
            System.out.println("【AAAA】新建表 "+fTableName+"  影响行数："+c);
        }

        if(formItemList!=null && formItemList.size()>0){
            //根据 column_change 属性值来更新表单数据表的列结构
            for(JsonNode formItem: formItemList){
                String title = formItem.get("title")==null?" ":formItem.get("title").asText();
                if(formItem.get("column_change").asText().equals("add")){
                    ccff.clear();
                    ff.put("table_name",fTableName);
                    ff.put("col_name",formItem.get("column_name").asText());
                    ff.put("title",title);
                    if(formItem.get("type").asText().equals("text")){
                        flowMapper.DDL_AddTableColumn_FlowSecForm_1000(ff);
                    }
                    else{
                        flowMapper.DDL_AddTableColumn_FlowSecForm_100(ff);
                    }
                }
                else if(formItem.get("column_change").asText().equals("change_type")){
                    ccff.clear();
                    ff.put("table_name",fTableName);
                    ff.put("col_name",formItem.get("column_name").asText());
                    ff.put("title",title);
                    if(formItem.get("type").asText().equals("text")){
                        flowMapper.DDL_ChangeTableColumnType_FlowSecForm_1000(ff);
                    }
                    else{
                        flowMapper.DDL_ChangeTableColumnType_FlowSecForm_100(ff);
                    }
                }
                else if(formItem.get("column_change").asText().equals("delete")){
                    ccff.clear();
                    ff.put("table_name",fTableName);
                    ff.put("col_name",formItem.get("column_name").asText());
                    flowMapper.DDL_DropTableColumn_FlowSecForm(ff);
                }
            }
        }

        return  true;
    }

    public Object GetCanvasData(String jsonStr) {
        ObjectNode data = Ctor.getObjectNode(jsonStr);
        String flow_id = data.get("flow_id").asText();
        Map<String,Object> result = new HashMap<String,Object>();

        List<Map<String,Object>> nodeList = Ctor.CoreMapper.USelect(
                Ctor.DMaker().Selector
                        .putFactorItem("flow_id", flow_id)
                        .From(fw_flow_node.class)
                        .Where("and flow_id=#{flow_id}","flow_id")
                        .OrderBy("remark")
                        .GetFactor());
        result.put("nodeList",nodeList);

        List<Map<String,Object>> lineList = Ctor.CoreMapper.USelect(
                Ctor.DMaker().Selector
                        .putFactorItem("flow_id", flow_id)
                        .From(fw_flow_line.class)
                        .Where("and flow_id=#{flow_id}","flow_id")
                        .GetFactor());
        result.put("lineList",lineList);

        List<Map<String,Object>> check_list = Ctor.CoreMapper.USelect(
                Ctor.DMaker().Selector
                        .putFactorItem("flow_id",flow_id)
                        .Select("*")
                        .From(fw_flow_node_check.class)
                        .Where("AND flow_node_id IN (SELECT id FROM fw_flow_node WHERE flow_id=#{flow_id} )")
                        .GetFactor());
        result.put("check_list",check_list);
        List<Map<String,Object>> check_param_list = Ctor.CoreMapper.USelect(
                Ctor.DMaker().Selector
                        .putFactorItem("flow_id",flow_id)
                        .Select("param.*,uu.nick_name AS uu_user_name,emp.name AS emp_name,oo.name AS org_name,role.name AS role_name")
                        .From(fw_flow_node_check_param.class,"param")
                        .LeftJoin(sys_user.class,"uu","uu.id = param.value")
                        .LeftJoin(biz_hrm_ei_basic.class,"emp","emp.emp_code = uu.emp_code")
                        .LeftJoin(sys_org.class,"oo","oo.id = param.value")
                        .LeftJoin(sys_role.class,"role","role.id = param.value")
                        .Where("AND param.flow_node_id IN (SELECT id FROM fw_flow_node WHERE flow_id=#{flow_id} )")
                        .GetFactor());
        result.put("check_param_list",check_param_list);

        return result;
    }

    @Transactional
    public Object SaveCanvasData(String jsonStr) {
        ObjectNode data = Ctor.getObjectNode(jsonStr);
        String flow_id = data.get("flow_id").asText();
        ArrayNode nodeList = (ArrayNode)data.get("nodeList");
        ArrayNode lineList = (ArrayNode)data.get("lineList");
        ArrayNode checkDataList = (ArrayNode)data.get("checkDataList");

        Ctor.HMapper.Save(fw_flow_node.class,nodeList,
                Ctor.DMaker().Deleter
                        .putFactorItem("flow_id", flow_id)
                        .From(fw_flow_node.class)
                        .Where("and flow_id=#{flow_id}","flow_id")
                        .GetFactor());
        Ctor.HMapper.Save(fw_flow_line.class,lineList,
                Ctor.DMaker().Deleter
                        .putFactorItem("flow_id", flow_id)
                        .From(fw_flow_line.class)
                        .Where("and flow_id=#{flow_id}","flow_id")
                        .GetFactor());

        //参与者数据更新
        List<fw_flow_node_check> nodeCheckModelList = new ArrayList<fw_flow_node_check>();
        List<fw_flow_node_check_param> nodeCheckParamModelList = new ArrayList<fw_flow_node_check_param>();
        for(JsonNode checkData: checkDataList){
            if(checkData.get("need_save").asText().equals("yes")){
                ArrayNode nodeCheckList = (ArrayNode)checkData.get("check_list");
                ArrayNode nodeCheckParamList = (ArrayNode)checkData.get("check_param_list");
                String flow_node_id = checkData.get("node_id").asText();
                if(nodeCheckList.size()>0){
                    for (JsonNode item : nodeCheckList) {
                        fw_flow_node_check nodeCheckModel = new fw_flow_node_check();
                        nodeCheckModel.setId(item.get("id").asText());
                        nodeCheckModel.setFlow_id(flow_id);
                        nodeCheckModel.setFlow_node_id(flow_node_id);
                        nodeCheckModel.setIface_id(item.get("iface_id").asText());
                        nodeCheckModelList.add(nodeCheckModel);
                    }
                    for (JsonNode item : nodeCheckParamList) {
                        fw_flow_node_check_param nodeCheckParamModel = new fw_flow_node_check_param();
                        nodeCheckParamModel.setId(item.get("id").asText());
                        nodeCheckParamModel.setFlow_id(flow_id);
                        nodeCheckParamModel.setFlow_node_id(flow_node_id);
                        nodeCheckParamModel.setCheck_id(item.get("check_id").asText());
                        nodeCheckParamModel.setValue(FlowType.getJsonNodeItemTextNull(item,"value"));
                        nodeCheckParamModel.setFlow_param_id(FlowType.getJsonNodeItemTextNull(item,"flow_param_id"));
                        nodeCheckParamModel.setIface_param_id(FlowType.getJsonNodeItemTextNull(item,"iface_param_id"));
                        nodeCheckParamModelList.add(nodeCheckParamModel);
                    }
                }

                Ctor.CoreMapper.UDelete(
                        Ctor.DMaker().Deleter
                                .putFactorItem("flow_node_id",flow_node_id)
                                .From(fw_flow_node_check.class)
                                .Where("AND flow_node_id = #{flow_node_id} ", "flow_node_id")
                                .GetFactor());
                Ctor.CoreMapper.UDelete(
                        Ctor.DMaker().Deleter
                                .putFactorItem("flow_node_id",flow_node_id)
                                .From(fw_flow_node_check_param.class)
                                .Where("AND flow_node_id = #{flow_node_id} ", "flow_node_id")
                                .GetFactor());
            }
        }
        if(nodeCheckModelList.size()>0){
            Ctor.HMapper.Save(nodeCheckModelList,null);
        }
        if(nodeCheckParamModelList.size()>0){
            Ctor.HMapper.Save(nodeCheckParamModelList,null);
        }

        return true;
    }


    public Object GetFlowParamList(String jsonStr) {
        ObjectNode data = Ctor.getObjectNode(jsonStr);
        String flow_id = data.get("flow_id").asText();
        List<Map<String,Object>> ret = Ctor.CoreMapper.USelect(
                Ctor.DMaker().Selector
                        .putFactorItem("flow_id",flow_id)
                        .From(fw_flow_param.class)
                        .Where("and flow_id = #{flow_id}","flow_id")
                        .OrderBy("param_name")
                        .GetFactor());
        return ret;
    }
    public Object UpsertFlowParam(String jsonStr) {
        return Ctor.HMapper.Upsert(fw_flow_param.class,jsonStr);
    }
    public Object DeleteParam(String jsonStr) {
        ObjectNode data = Ctor.getObjectNode(jsonStr);
        String id = data.get("id").asText();
        Ctor.CoreMapper.UDelete(
                Ctor.DMaker().Deleter
                        .putFactorItem("id",id)
                        .From(fw_flow_param.class)
                        .Where("AND id = #{id} ", "id")
                        .GetFactor());

        return true;
    }

}
